﻿using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
using DevExpress.Xpo;
using System.ComponentModel;

namespace EasyXaf.EntityDesigner.BusinessObjects.Enums;

/// <summary>
/// 枚举值
/// </summary>
[XafDisplayName("枚举值")]
[XafDefaultProperty(nameof(Name))]
public partial class EnumValue : BaseObject
{
	private string _name;
	private string _caption;
	private string _imageName;
	private int? _value;
	private double _order;
	private string _description;
	private Enumeration _enum;

	/// <summary>
	/// 名称
	/// </summary>
	[XafDisplayName("名称")]
	[RuleRequiredField]
	public string Name
	{
		get => _name;
		set => SetPropertyValue(nameof(Name), ref _name, value);
	}

	/// <summary>
	/// 标题
	/// </summary>
	[XafDisplayName("标题")]
	public string Caption
	{
		get => _caption;
		set => SetPropertyValue(nameof(Caption), ref _caption, value);
	}

	/// <summary>
	/// 图像名
	/// </summary>
	[XafDisplayName("图像名")]
	[Browsable(false)]
	public string ImageName
	{
		get => _imageName;
		set => SetPropertyValue(nameof(ImageName), ref _imageName, value);
	}

	/// <summary>
	/// 值
	/// </summary>
	[XafDisplayName("值")]
	public int? Value
	{
		get => _value;
		set => SetPropertyValue(nameof(Value), ref _value, value);
	}

	/// <summary>
	/// 顺序
	/// </summary>
	[XafDisplayName("顺序")]
	public double Order
	{
		get => _order;
		set => SetPropertyValue(nameof(Order), ref _order, value);
	}

	/// <summary>
	/// 描述
	/// </summary>
	[XafDisplayName("描述")]
	[Browsable(false)]
	[Size(SizeAttribute.Unlimited)]
	public string Description
	{
		get => _description;
		set => SetPropertyValue(nameof(Description), ref _description, value);
	}

	/// <summary>
	/// 枚举
	/// </summary>
	[XafDisplayName("枚举")]
	[Association("Values-Enum")]
	public Enumeration Enum
	{
		get => _enum;
		set => SetPropertyValue(nameof(Enum), ref _enum, value);
	}

	public EnumValue(Session session)
		: base(session)
	{
	}
}
